<!--
 * @Author: your name
 * @Date: 2021-03-11 22:49:46
 * @LastEditTime: 2021-03-16 22:13:22
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: \hmmm-frontend-117-10\src\module-hmmm\pages\ppp.html
-->
<!DOCTYPE html>
<html lang="zh-CN">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <input type="text" id="change">
</body>

</html>
<script>
  /* function fun() {
    console.log(1);
  } */
  var input = document.getElementById('change')
  input.oninput = time()
  function time() {
    var times = 0
    return function () {
      var newtime = Date.now()//获得当前时间
      if (newtime - times > 1000) {//当前时间-之前的时间>1秒
        console.log(1);
        times = newtime//   注意 如果对倒，新时间就变成0了
      }
    }
  }
  /* input.oninput = time(fun,1000)

  function time(fun,times) {
    var pre = 0//储存上次时间
    return function(){
      var now=Date.now()//获取当前时间
      if(now-pre>times){//当前时间 - 上次时间 >1000
        fun()
        pre=now//当前时间 = 上次时间
      }
    }
  } */
</script>